<?php

namespace app\admin\validate;

class AdminMenusValidate extends BaseValidate
{
    protected $rule = [
        'id' => 'require|integer',
        'pid' => 'integer',
        'title' => 'require|length:1,20',
        'route' => 'length:0,50',
        'redirect' => 'length:0,50',
        'component_name' => 'require|length:0,50',
        'component' => 'length:0,50',
        'sort' => 'integer',
        'status' => 'in:enable,disable',
    ];

    protected $message = [
        'id.require' => 'id必须',
        'id.integer' => 'id必须是整数',
        'pid.integer' => 'pid必须是整数',
        'title.require' => '标题必须',
        'title.length' => '标题长度1-20',
        'route.length' => '路由地址长度1-50',
        'redirect.length' => '路由地址长度1-50',
        'component_name.require' => '组件名称不能为空',
        'component_name.length' => '组件名称长度超过限制',
        'component.length' => '组件路径长度1-50',
        'sort.int' => '排序必须是整数',
        'status.in' => '状态值错误',
    ];

    protected $scene = [
        'create' => ['pid', 'title', 'route', 'redirect', 'component_name', 'component', 'sort', 'status'],
        'update' => ['id', 'pid', 'title', 'route', 'redirect', 'component_name', 'component', 'sort', 'status'],
    ];
}